{extend name="web/public/base" /}
{block name="header"}
{/block}
{block name="main"}
<section class="scrollable padder">
    <ul class="breadcrumb no-border no-radius b-b b-light pull-in">
        <li><a><i class="fa fa-home"></i> 首页</a></li>
        <li class="active">购物商城</li>
        <li class="active">{$title}</li>
    </ul>
    <div class="row">
        <div class="col-sm-12">
            <section class="panel panel-default">
                <header class="panel-heading font-bold">{$title}</header>
                <div class="panel-body">
                    <form action="{:url('')}" method="post" id="ajaxform" onsubmit="return false;">
                        <div class="row col-md-10">
                            <div class="row col-lg-12">
                                <div class="form-group col-sm-6">
                                    <label>商品名称</label>
                                    <select class="form-control" name="goods_id">
                                        {foreach name='goods' item='vo'}
                                        <option value="{$vo.id}">{$vo.goods_name}</option>
                                        {/foreach}
                                    </select>
                                </div>
                                <div class="form-group col-sm-6">
                                    <label>商品成本</label>
                                    <input type="text" name="original_price" class="form-control" placeholder="商品成本">
                                </div>
                            </div>

                            <div class="row col-lg-12">
                                <div class="form-group col-sm-6">
                                    <label>开始时间</label>
                                    <input type="text" id="start" name="begin_date" class="form-control" placeholder="开始时间" readonly>
                                </div>
                                <div class="form-group col-sm-6">
                                    <label>结束时间</label>
                                    <input type="text" id="end" name="end_date" class="form-control" placeholder="结束时间" readonly>
                                </div>
                            </div>

                            <footer class="panel-footer text-right bg-light lter col-sm-12">
                                <button type="submit" class="btn btn-success btn-s-xs">提 交</button>
                            </footer>
                        </div>
                    </form>
                </div>
            </section>
        </div>
    </div>
</section>
{/block}
{block name="script"}
<script type="text/javascript">
    $(function () {
        $.validator.setDefaults({
            submitHandler: function () {
                ajaxSubmit();
            },
            highlight: function (element, errorClass) {
                $(element).css('border', '2px solid red');
            },
            unhighlight: function (element, errorClass) {
                $(element).css('border', '1px solid green');
            }
        });

        $('#ajaxform').validate({
//            rules: {
//                goods_name: "required"
//            },
//            messages: {
//                goods_name: "请输入商品名称"
//            }
        });
    })

    var start = {
        elem: '#start',
        format: 'YYYY-MM-DD hh:mm:ss',
        min: '2010-01-01 00:00:00', //设定最小日期为当前日期
        max: '2099-12-31 23:59:59', //最大日期
        istime: true,
        istoday: false,
        choose: function (datas) {
            end.min = datas; //开始日选好后，重置结束日的最小日期
            end.start = datas //将结束日的初始值设定为开始日
        }
    };
    var end = {
        elem: '#end',
        format: 'YYYY-MM-DD hh:mm:ss',
        min: '2010-01-01 00:00:00', //设定最小日期为当前日期
        max: '2099-12-31 23:59:59', //最大日期
        istime: true,
        istoday: false,
        choose: function (datas) {
            start.max = datas; //结束日选好后，重置开始日的最大日期
        }
    };
    laydate(start);
    laydate(end);
    $("#begin").click(function () {
        laydate(start);
    });

    $("#end").click(function () {
        laydate(end);
    });
</script>
{/block}
